package com.springcloud.hystrix;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author zheny
 * @EnableHystrix和@EnableCircuitBreaker区别？
 *  @EnableHystrix继承了@EnableCricuitBreaker
 *
 *  EnableCricuitBreaker：开启熔断器
 *
 *  @SpringBootApplication
 *  @EnableDiscoveryClient
 *  @EnableCircuitBreaker
 *  @SpringCloudApplication:这个注解包含了上面三个注解，因此在这里也可以使用这个注解代替
 */
@EnableHystrix
@EnableEurekaClient
@EnableFeignClients
@SpringBootApplication
public class HystrixApplication {

    public static void main(String[] args) {
        SpringApplication.run(HystrixApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate gettemplate() {
        return  new RestTemplate();
    }
}
